/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.core;

import org.eclipse.emf.ecore.EClass;

/**
 * @author Zhao Yi
 *
 */
public class MetaUnlimitedNatural extends MetaDataType {
	protected static final int VALUE_DEFAULT = -1;
	
	public int value = VALUE_DEFAULT;
	
	protected static final boolean UNLIMITED_DEFAULT = true;
	
	public boolean isUnlimited = UNLIMITED_DEFAULT;
	
	public MetaUnlimitedNatural(){}
	
	public MetaUnlimitedNatural(boolean unlimited, int val){
		this.isUnlimited = unlimited;
		this.value = val;
	}
	
	public void setValue(int newVal){
		int old = this.value;
		this.value = newVal;
		this.firePropertyChange("value",old,newVal);
	}
	
	public void setIsUnlimited(boolean newUn){
		boolean old = this.isUnlimited;
		this.isUnlimited = newUn;
		this.firePropertyChange("isUnlimited",old,newUn);
	}
	
	public boolean isIsUnlimited() {
		return isUnlimited;
	}

	public int getValue() {
		return value;
	}
	
	@Override
	protected EClass eStaticClass() {
		return EMetaModelPackage.Literals.EMETA_UNLIMITED_NATURAL;
	}
	
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EMetaModelPackage.EMETA_UNLIMITED_NATURAL__VALUE:
				return new Integer(getValue());
			case EMetaModelPackage.EMETA_UNLIMITED_NATURAL__IS_UNLIMITED:
				return isIsUnlimited() ? Boolean.TRUE : Boolean.FALSE;
		}
		return super.eGet(featureID, resolve, coreType);
	}
}